package top.scsoul.voes.examination.service.impl;

import top.scsoul.voes.examination.entity.QuestionJudgment;
import top.scsoul.voes.examination.mapper.QuestionJudgmentMapper;
import top.scsoul.voes.examination.service.QuestionJudgmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (QuestionJudgment)表服务实现类
 *
 * @author guolei
 * @since 2021-07-23 13:10:55
 */
@Service("questionJudgmentService")
public class QuestionJudgmentServiceImpl implements QuestionJudgmentService {
    @Resource
    private QuestionJudgmentMapper questionJudgmentMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public QuestionJudgment queryById(Integer id) {
        return this.questionJudgmentMapper.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<QuestionJudgment> queryAllByLimit(int offset, int limit) {
        return this.questionJudgmentMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param questionJudgment 实例对象
     * @return 实例对象
     */
    @Override
    public QuestionJudgment insert(QuestionJudgment questionJudgment) {
        this.questionJudgmentMapper.insert(questionJudgment);
        return questionJudgment;
    }

    /**
     * 修改数据
     *
     * @param questionJudgment 实例对象
     * @return 实例对象
     */
    @Override
    public QuestionJudgment update(QuestionJudgment questionJudgment) {
        this.questionJudgmentMapper.update(questionJudgment);
        return this.queryById(questionJudgment.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.questionJudgmentMapper.deleteById(id) > 0;
    }
}